package com.sls.game.parser.ohfei;

import java.io.File;
import java.util.List;

import com.sls.game.pojo.OhFeiServerInfo;

/**
 * 
 * @description 请求访问url拼装
 * @author Wangxuegang
 * @date 2012-9-27
 * 
 */
public class OhFeiAssembleHttpUrl {

	/**
	 * 拼装http请求的url
	 * 
	 * @param paraStr
	 *            所传参数字符串拼接
	 * @param path
	 *            路径
	 * @return
	 */
	public static String assembleHttpUrl(String paraStr, String path) {
		String url = "";
		String address = "";
		// 从xml配置文件中读取访问地址
		List<OhFeiServerInfo> serverList = OhFeiServerSaxParseXml
				.parseXmlString("conf" + File.separator + "ohFeiServer.xml");
		if (serverList.size() > 0) {
			for (OhFeiServerInfo info : serverList) {
				address = info.getAddress().trim();
			}
		}

		StringBuffer strBuf = new StringBuffer();
		strBuf.append("http://");
		strBuf.append(address.trim());
		strBuf.append("/");
		strBuf.append(path.trim()); // 端口号和？之间的内容
		strBuf.append("?");

		strBuf.append(paraStr.trim());
		url = strBuf.toString().trim();

		return url;
	}

}
